package yunhe.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import yunhe.biz.IProcureBiz;
import yunhe.biz.impl.CusBizImpl;
import yunhe.biz.impl.ProcureBizImpl;
import yunhe.biz.impl.StorageBizImpl;
import yunhe.biz.impl.SupBizImpl;
import yunhe.entity.Customer;
import yunhe.entity.EmpMsg;
import yunhe.entity.Product;
import yunhe.entity.Storage;
import yunhe.entity.Supplier;
@WebServlet(name="AddStorageServlet",urlPatterns="/AddStorageServlet")
public class AddStorageServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		StorageBizImpl biz=new StorageBizImpl();
		String stoId=request.getParameter("stoId");
		String stoName=request.getParameter("stoName");
		String empName=request.getParameter("empName");
		String stoAddr=request.getParameter("stoAddr");
		String isDefaultSto=request.getParameter("isDefaultSto");
		String stoPs=request.getParameter("stoPs");
		EmpMsg empMsg=biz.getEmpByName(empName);
		System.out.println(empMsg.getWorkId()+empMsg.getName());
		Storage storage=new Storage(stoId, stoName, empMsg, stoAddr, Integer.parseInt(isDefaultSto), stoPs);
		PrintWriter out=response.getWriter();
		if(biz.addStorage(storage)){
			out.print("<script>alert('添加仓库成功');location.href='/purchase/addProduct.jsp'</script>");
		}else{
			out.print("<script>alert('添加仓库失败');location.href='/purchase/addProduct.jsp'</script>");
		}
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		doGet(req, resp);
	}
}
